package edu.gatech.mobile.scene.image.util;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import edu.gatech.mobile.scene.model.ImageInfo;

public class ImageGenerator {
	
	public static Bitmap generateHorizonImagesColor(ImageInfo image) {
		
			Point[] horizonPoints = image.getHorizonPoints();
			Point point1 = horizonPoints[0];
			Point point2 = horizonPoints[1];

			double slope = (point1.y - point2.y) * 1.0 / (point1.x - point2.x)
					* 1.0;
			int height = ((point2.y - point1.y) * point1.x)
					/ (point2.x - point1.x);
			int intercept = point1.y - height;
			
			Bitmap bitmap = BitmapFactory.decodeFile(image.getImagePath());
			bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
			int leftY = (int) (0 * slope + intercept);
			int rightY = (int) ((bitmap.getWidth()) * slope + intercept);
			
			Canvas canvas = new Canvas(bitmap);
			Paint paint = new Paint();
			paint.setColor(Color.RED);
			paint.setStrokeWidth(10); 
			canvas.drawLine(0, leftY, bitmap.getWidth(), rightY, paint);
			
			return bitmap;
		
	}

}
